<% include ../public/page_header.html %>
    <script type="text/javascript" src="/public/admin/js/jqPaginator.js"></script>
    <!--
        列表展示
    -->
    <div class="panel panel-default">
        <div class="panel-heading">
            <a href="/<%=adminPath%>/product/add" class="btn btn-primary">增加菜品</a>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered">
                <thead>
                    <tr class="th">
                        <th>菜品名称</th>
                        <th>菜品分类</th>
                        <th>菜品图片</th>
                        <th>增加时间</th>
                        <th class="text-center">排序</th>
                        <th class="text-center">推荐</th>
                        <th class="text-center">热销</th>
                        <th class="text-center">状态</th>

                        <th class="text-center">操作</th>
                    </tr>
                </thead>
                <%for(var i=0;i<list.length;i++){%>
                    <tr>

                        <td>
                            <%=list[i].title%>
                        </td>
                        <td>
                            <%=list[i].ProductCate.title%>
                        </td>
                        <td><img width="80" src="<%=cosUrl%>/<%=list[i].imgUrl%>" alt="" srcset=""></td>

                        <td>
                            <%=helper.formatTime(list[i].addTime)%>
                        </td>

                        <td class="text-center">
                            <%=list[i].sort%>
                        </td>

                        <td class="text-center chStatus" data-adminPath="<%=adminPath%>" data-id="<%=list[i].id%>"
                            data-model="Product" data-field="isBest">

                            <%if(list[i].isBest==1){%>

                                <img src="/public/admin/images/yes.gif" />

                                <%}else{%>
                                    <img src="/public/admin/images/no.gif" />
                                    <%}%>
                        </td>

                        <td class="text-center chStatus" data-adminPath="<%=adminPath%>" data-id="<%=list[i].id%>"
                            data-model="Product" data-field="isHot">

                            <%if(list[i].isHot==1){%>

                                <img src="/public/admin/images/yes.gif" />

                                <%}else{%>
                                    <img src="/public/admin/images/no.gif" />
                                    <%}%>
                        </td>

                        <td class="text-center chStatus" data-adminPath="<%=adminPath%>" data-id="<%=list[i].id%>"
                            data-model="Product" data-field="status">

                            <%if(list[i].status==1){%>

                                <img src="/public/admin/images/yes.gif" />

                                <%}else{%>
                                    <img src="/public/admin/images/no.gif" />
                                    <%}%>
                        </td>

                        <td class="text-center">

                            <a href="/<%=adminPath%>/product/edit?id=<%=list[i].id%>">编辑</a>　

                            <a class="delete" href="/<%=adminPath%>/product/delete?id=<%=list[i].id%>">删除</a>
                        </td>
                    </tr>
                    <%}%>


            </table>
        </div>
        
    </div>

    <div id="pagination" class="pagination">
    </div>
    </body>
    <script>
        $('#pagination').jqPaginator({ 
            totalPages: <%=totalPages%>, 
            visiblePages: 5, 
            currentPage: <%=page%>, 
            onPageChange: function (num, type) { 
               console.log(type);
               console.log('当前第' + num + '页'); 
               if(type=="change"){
                    location.href="/<%=adminPath%>/product?page="+num;
               }
            } 
        });
    </script>

    </html>